brackets=input()
def skobki(brackets):
    s=[]
    sk={'(': ')','{':'}','[':']','<':'>'}
    for char in brackets:
        if char in sk:
            s.append(char)
        elif char in sk.values():
            if not s or sk[s.pop()] !=char:
                return False
    return len(s)==0
print(skobki(brackets))
